package com.haha.helloworld;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class TestViewActivity extends AppCompatActivity {
    private TextView tv_4;
    private TextView tv_5;
    private TextView tv_6;
    private TextView tv_7;
    private Button hahaButton2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_view);
        tv_4=(TextView) findViewById(R.id.tv_4);
        //加一个中划线的效果
        tv_4.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        //去除下划线的锯齿
        tv_4.getPaint().setAntiAlias(true);

        tv_5=(TextView) findViewById(R.id.tv_5);
        //添加下划线效果
        tv_5.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);

        //通过代码设置内容
        tv_6=(TextView) findViewById(R.id.tv_6);
        tv_6.setText(Html.fromHtml("<u>这里是html代码实现的效果</u>"));


        //通过代码设置内容
        tv_7=(TextView) findViewById(R.id.tv_7);
        tv_7.setClickable(true);

        //通过findViewById方法通过id找到我们的button，返回的是一个View类型
        View viewById = findViewById(R.id.hahaButton2);
        //将View类型转换为Button，再赋值给hahaButton
        hahaButton2=(Button) viewById;
        //给这个button设置一个点击事件
        hahaButton2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //跳转到其他页面
                Intent intent = new Intent(TestViewActivity.this,MainActivity.class);
                startActivity(intent);
            }
        });

    }
}